package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepForecastResult;
import com.ruoyi.deeplearn.service.IDeepForecastResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型预测结构Controller
 *
 * @author rww
 * @date 2024-09-15
 */
@RestController
@RequestMapping("/deeplearn/forecastResult")
public class DeepForecastResultController extends BaseController
{
    @Autowired
    private IDeepForecastResultService deepForecastResultService;

    /**
     * 查询模型预测结构列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepForecastResult deepForecastResult)
    {
        startPage();
        List<DeepForecastResult> list = deepForecastResultService.selectDeepForecastResultList(deepForecastResult);
        return getDataTable(list);
    }

    @GetMapping("/list/all")
    public AjaxResult listAll(DeepForecastResult deepForecastResult)
    {
        List<DeepForecastResult> list = deepForecastResultService.
                selectDeepForecastResultList(deepForecastResult);
        return AjaxResult.success(list);
    }

    /**
     * 导出模型预测结构列表
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:export')")
    @Log(title = "模型预测结构", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepForecastResult deepForecastResult)
    {
        List<DeepForecastResult> list = deepForecastResultService.selectDeepForecastResultList(deepForecastResult);
        ExcelUtil<DeepForecastResult> util = new ExcelUtil<DeepForecastResult>(DeepForecastResult.class);
        util.exportExcel(response, list, "模型预测结构数据");
    }

    /**
     * 获取模型预测结构详细信息
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepForecastResultService.selectDeepForecastResultById(id));
    }

    /**
     * 新增模型预测结构
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:add')")
    @Log(title = "模型预测结构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepForecastResult deepForecastResult)
    {
        return toAjax(deepForecastResultService.insertDeepForecastResult(deepForecastResult));
    }

    /**
     * 修改模型预测结构
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:edit')")
    @Log(title = "模型预测结构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepForecastResult deepForecastResult)
    {
        return toAjax(deepForecastResultService.updateDeepForecastResult(deepForecastResult));
    }

    /**
     * 删除模型预测结构
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:forecastResult:remove')")
    @Log(title = "模型预测结构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepForecastResultService.deleteDeepForecastResultByIds(ids));
    }
}
